package OIandFile;
import java.io.File;
import java.util.*;

public class name {
    public static void main(String[] args) {
        searchfile(new File("E:\\java_learning")," Math");
    }

    public static void searchfile(File file, String filename){
        if (file == null) {
            System.out.println("File not found: " + file.getAbsolutePath());
            return;
        }
        if (!file.isDirectory()) {
            if (file.getName().contains(filename)) {
                System.out.println("找到对应的文件：" + file.getAbsolutePath());
            }
            return;
        }
        final File[] files = file.listFiles();
        if (files != null) {
            for (File file1 : files) {
                searchfile(file1, filename);
            }
        } else {
            System.out.println("No files found in directory: " + file.getAbsolutePath());
        }
    }
}
